<% content_for :header_tags do %>
 <%= stylesheet_link_tag 'statistics', :plugin => 'redmine_statistics' %>
 <%= javascript_include_tag 'WdatePicker.js', :plugin => 'redmine_statistics' %>
 <%= javascript_include_tag 'statistics', :plugin => 'redmine_statistics' %>
<% end %>

<div id="statistic">
  <h2>ISSUES TREND</h2>
  <div id="myheader">  
    <div class="buttons">
      <a href=<%= @back_url %> class="negative">
        <%= image_tag('back.png', :plugin => 'redmine_statistics') %>
        Back
      </a>
      <% form_tag(:action => 'index') do %>
        <div class="choice">
        <span>报表式样:</span>
        <select name="chart_id" onchange="checkTrendChart(this)">
          <option value="1">标准报表</option>
          <option value="2">线型图</option>
        </select>
        <span>项目列表:</span>
        <select name="project_id" onchange="<%= remote_function(:update => "version_container",
                                                                :url => {:controller => 'statistics', :action => 'versions_ajax'},
                                                                :with => "'project_id='+value",
                                                                :success => "show_result(xhr)",
                                                                :failure => "show_error(xhr)",
                                                                :complete => "new Effect.Highlight('version_container')")%>">
          <% @projects.each do |project| %>
          <option value=<%= project.id %>><%= project.name %></option>
          <% end %>
        </select>
        <span id="version_container">
          <span id="l_version">目标版本:</span>
          <select name="version_id" id="s_version">
            <%  @versions.each do |version| %>
            <option value=<%= version.id %>><%= version.name %></option>
            <% end %>
            <option value=" ">未指定目标版本</option>
            <option value="all">所有目标版本</option>
          </select>
        </span>
        <span id="l_priority">优先级:</span>
        <select name="priority_id" id="s_priority">
          <option value="all">所有优先级</option>
          <% @priorities.each do |priority| %>
            <option value=<%= priority.id %>><%= priority.name %></option>
          <% end %>
        </select>
        <span>追踪类型:</span>
        <select name="tracker_id" id="s_tracker">
          <option value="all">所有类型</option>
          <% @trackers.each do |tracker| %>
            <option value=<%= tracker.id %>><%= tracker.name %></option>
          <% end %>
        </select>
        <span>开始日期:</span>
        <input name="date_from" class="Wdate" type="text" onClick="WdatePicker()"/>
        <span>结束日期:</span>
        <input name="date_to" class="Wdate" type="text" onClick="WdatePicker()"/>
        </div>
        <br>
        <br>
        <div class="toright">
          <button type="submit" class="positive">
            <%= image_tag('database_search.png', :plugin => 'redmine_statistics') %>
            Generate
          </button>
          <button type="reset" class="positive">
            <%= image_tag('search_cancel.png', :plugin => 'redmine_statistics') %>
            Reset
          </button>
        </div>
      <% end %>
    </div>
  </div> 
</div>

<%if params[:chart_id] == '2' %>
 <%= render :partial => 'trend_chart' %>
<%  else %>
 <%= render :partial => 'active_issues' %>
<% end %>

